package com.mxpio.erp.common.equipment.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpioframework.filestorage.entity.MxpioFileInfo;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.Dept;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;

/**
 * @Description: 设备检定
 * @Author: qiubo
 * @Date: 2023-12-18
 * @Version: v1.0
 */
@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_EQUIPMENT_CALIBRATION")
@Schema(description="设备检定")
public class EquipmentCalibration  extends BaseEntity {

    private static final long serialVersionUID=1L;

    @Id
    @Column(name = "CAL_CODE_", updatable = false)
    @Schema(description = "工单编码")
    private String calCode;

    @Column(name = "EQP_CODE_")
    @Schema(description = "设备编码")
    @Dict(dicCode="eqpCode", dicEntity = Equipment.class, dicText = "eqpCode")
    private String eqpCode;

    @Column(name = "TARGET_ID_")
    @Schema(description = "资产编码")
    private String targetId;

    @Column(name = "EQP_NAME_")
    @Schema(description = "设备名称")
    private String targetName ;

    @Column(name = "SPEC_TYPE_")
    @Schema(description = "规格型号")
    private String specType;

    @Column(name = "USE_DEPT_ID_")
    @Schema(description = "使用单位")
    @Dict(dicCode = "deptCode", dicEntity = Dept.class, dicText = "deptName")
    private String useDeptId;

    @Column(name = "EQP_TYPE_Id_")
    @Schema(description = "设备分类")
    @Dict(dicCode="code", dicEntity = EquipmentCategory.class, dicText = "name")
    private String eqpTypeId;

    @Column(name="LAY_ADDR_")
    @Schema(description = "使用地点")
    private String layAddr;

    @Column(name = "CALIBRATION_TYPE_")
    @Schema(description = "检定类型")
    @Dict(dicCode = "MB_ERP_EQUIPMENT_CALIBRATION_TYPE")
    private String calibrationType;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @Schema(description = "检定日期")
    @Column(name = "CALIBRATION_DATE_")
    private Date calibrationDate;

    /**实际开始时间*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @Schema(description = "实际开始日期")
    @Column(name = "ACTUAL_START_DATE_")
    private Date actualStartDate;

    /**
     * 此为实际结束日期or实际检测日期
     */
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @Schema(description = "实际结束日期/实际检测日期")
    @Column(name = "ACTUAL_END_DATE_")
    private Date actualEndDate;

    @Column(name = "INSPECT_DUTY_USER_")
    @Schema(description = "检定负责人")
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String inspectDutyUser;

    @Column(name = "EXECUTION_STATUS_")
    @Schema(description = "执行状态")
    @Dict(dicCode = "MB_ERP_EQUIPMENT_CALIBRATION_STATUS")
    private String executionStatus;

    @Column(name = "CREATE_BY_")
    @Schema(description = "创建人")
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String createBy;

    @Column(name = "CREATE_DATE_")
    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date createDate;

    @Column(name = "TEST_UNIT_")
    @Schema(description = "检测单位")
    @Dict(dicCode = "MB_ERP_EQUIPMENT_CALIBRATION_TEST_UNIT")
//    @JsonProperty(value = "TestUnit")
    private String testUnit;


    @Column(name = "TEST_RESULT_")
    @Schema(description = "检测结果")
    @Dict(dicCode = "MB_ERP_EQUIPMENT_CALIBRATION_TEST_RESULT")
//    @JsonProperty(value = "testResult")
    private String testResult;

    @Column(name = "MEMO_")
    @Schema(description = "备注")
    private String memo;

    @Schema(description = "附件")
    @Column(name = "FILE_")
    @Dict(dicCode = "fileNo", dicEntity = MxpioFileInfo.class, dicText = "fileName")
    private String file;

    @Column(name = "OPERATION_")
    @Schema(description = "操作")
    private String operation;

//
//    @Override
//    public String initTypeCode() {
//        return "QCI";
//    }
}
